- /* snmchkar.cpp by K.Tsuru */
- // function ID = 102 DRADIX, BRADIX
- /***************************************************
- SNumber class
- It provides the information of figure position.
- The normalization has to be done.
- By the argument id the place where an error occures
- can be identified in debug.
- ***************************************************/
- #ifndef SN_H
- #include "sn.h"
- #endif
- static const char* const func = "CheckArray";
- void SNumber::CheckArray(int id){
- if(sign == UNDECIDED ) SetError(UNDEC_VALUE, func, id);
-
- uint fsz = figure.size();
- #ifndef NDEBUG
- if(fsz < minArraySize){
- fprintf(stderr, " fsz = %u\n", fsz);
- SetError(FATAL, func, id);;
- }
- #endif
- const fType* fe = figure.Elements();
-
- aTail=0;
- while( (aTail < fsz) && (fe[aTail] == 0) ) aTail++; //from the tail
-
- if( aTail == fsz ){ //All the elements are zero.
- SetZero(); return;
- }
- //Here, there must be non-zero element(s) anywhere.
- aHead = fsz-1;
- while( (fe[aHead] == 0) && aHead) aHead--; //from the head
-
- // DoCutDown() does not change the values of aHead and aTail.
- if( (2u*(aHead+1) <= fsz) && (CutDown() == ENABLE) ) DoCutDown();
-
- //for debug
- #ifndef NDEBUG
- fe = figure.Elements();
- if(fe[aHead] && (sign == ZERO) ){//figure is contradictory to the sign.
- SetError(FATAL, func, id);
- }
- fType radix = Radix();
- for(uint i = aTail; i<= aHead; i++){
- if(fe[i] >= radix){ //not be normalized
- fprintf(stderr, "figure[%u] = %u, id = %d\n", i, fe[i], id);
- SetError(FATAL,"CheckArray()",id);
- }
- }
- #endif
- }
snmchkar.cpp : last modifiled at 2017/03/13 14:32:01(1,558 bytes)
created at 2016/04/11 11:36:47
The creation time of this html file is 2017/10/27 10:59:17 (Fri Oct 27 10:59:17 2017).